using UnityEngine;
using System.Collections;

public class LargeCar : MonoBehaviour {

	// Use this for initialization
	void Start () {
		rigidbody.velocity = Vector3.up * -5;
	}
	
	private void OnTriggerEnter (Collider other)
	{
		if(other.gameObject.tag == "Car")
		{	
			collider.isTrigger = false;
			Controller.LevelUp();
			StartCoroutine(Shrink());
			Destroy(other.gameObject);
			gameObject.AddComponent<Car>();
		}
	}
	
	private IEnumerator Shrink ()
	{		
		while(transform.localScale.x > 1)
		{
			transform.localScale = transform.localScale * 0.9f;
			yield return null;
		}
		
		Destroy(this);
	}
}
